//
//  HistoryTableCell.m
//  GoldOperationClient
//
//  Created by yaxue wang on 16/8/5.
//  Copyright © 2016年 展鸿科技. All rights reserved.
//

#import "HistoryTableCell.h"
#import "historyModel.h"
@interface HistoryTableCell()

@property (nonatomic, strong) UILabel *nameLab;
@property (nonatomic, strong) UILabel *contexLab;
@property (nonatomic, strong) UILabel *timeLab;
@property (nonatomic, strong) UILabel *line;

@end
@implementation HistoryTableCell

- (void)initView{
    [super initView];
    self.backgroundColor =[UIColor whiteColor];
    
    
    self.nameLab = [[UILabel alloc]init];
    [self addSubview:self.nameLab];
    [self.nameLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self).offset(-15);
        make.top.equalTo(self).offset(15);
        make.width.equalTo(@(120));
    }];
    self.nameLab.textColor =LightFontColor;
    self.nameLab.font =F(12);
    self.nameLab.textAlignment=NSTextAlignmentRight;
    self.timeLab =[[UILabel alloc]init];
    [self addSubview:self.timeLab];
    
    [self.timeLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self).offset(-15);
        make.top.equalTo(self.nameLab.mas_bottom).offset(10);
        make.width.equalTo(@(120));
    }];
    self.timeLab.font =F(12);
    self.timeLab.textAlignment=NSTextAlignmentRight;
    self.timeLab.textColor =LightFontColor;
    
    self.contexLab =[[UILabel alloc]init];
    [self addSubview:self.contexLab];
    [self.contexLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(15);
        make.right.equalTo(self.nameLab.mas_left).offset(-5);
        make.centerY.equalTo(self);
        
    }];
    self.contexLab.textColor =FontColor;
    self.contexLab.font =F(12);
    self.contexLab.numberOfLines=0;
    self.contexLab.textAlignment =NSTextAlignmentLeft;
    
    [self setSelectionStyle:UITableViewCellSelectionStyleNone];
}
- (void)setModel:(id)model{
    
 
    
    historyModel *order = model;
    if (order.HH_name ==nil||[order.HH_name isEqualToString:@""]) {
        self.nameLab.text =@"";
        
    }else
    {
        self.nameLab.text=order.HH_name;
    }
    if(order.HH_type_name==nil||(order.HH_content ==nil||[order.HH_content isEqualToString:@""]))
    {
        if (order.HH_type_name==nil) {
             self.contexLab.text =[NSString stringWithFormat:@"%@",order.HH_content];

        }else
        {
             self.contexLab.text =[NSString stringWithFormat:@"【%@】",order.HH_type_name];

        }

        
    }else
    {
     self.contexLab.text =[NSString stringWithFormat:@"【%@】%@",order.HH_type_name,order.HH_content];
    }
    NSString  *a = order.HH_created;
    if (a ==nil||[a isEqualToString:@""]) {
        
        self.timeLab.text =@"";
        
    }else
    {
        self.timeLab.text =a;
    }
    [self.line setFrame:CGRectMake(0,self.bounds.size.height-0.5 , WindowWidth, 0.5)];
    
}

@end
